//
// Created by liushuai on 2020/4/2.
//
#include "maxSubArrayDp.h"
<<<<<<< HEAD:cxx/algorithm/src/maxSubArrayDp.cc
int maxSubArrayDp(vector<int>& nums){
    int length = nums.size();
    if(length == 0)
        return 0;
    else{
        int sum = nums.at(0);
        int currentInt = nums.at(0);
        for(int i=1;i<length;i++){
            if(currentInt>0)
                currentInt+=nums.at(i);
            else
                currentInt=nums.at(i);
            if(currentInt>sum)
                sum = currentInt;
        }
        return sum;
    }
=======
int maxSubArrayDp(vector<int>& nums) {
  int length = nums.size();
  if (length == 0)
    return 0;
  else {
    int sum = nums.at(0);
    int currentInt = nums.at(0);
    for (int i = 1; i < length; i++) {
      if (currentInt > 0)
        currentInt += nums.at(i);
      else
        currentInt = nums.at(i);
      if (currentInt > sum) sum = currentInt;
    }
    return sum;
  }
>>>>>>> dev:cxx/algorithm/common/src/maxSubArrayDp.cc
}
